﻿/******************************************************************************
* File description: PreferenceSettings.qml
* Function: 系统设置页面（带淡入淡出过渡效果）
* Current Version: 1.2
* Author: 陈乃瑞
* Date: 2025-08-19
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.2
import QtQuick.Controls 2.12
import QtMultimedia 5.14
import "./preferenceSettings"
import "./components/"
import "./report"
import "./promptBox"

ApplicationWindow {
    id: preferenceSettings
    width: 1600*dp
    height: 960*dp
    minimumWidth: 1600*dp
    minimumHeight: 960*dp

    readonly property real dp: config.dp
    property int pbflag: 3

    modality: {
        if(showDebug)       return Qt.NonModal
        else                return Qt.WindowModal

    }
    title: qsTr("系统设置")
    property int btfl1: 0
    property bool passflag: false

    property var box_operating: box_operatingPref
    property int curPage: 3     // 0 实验配置 1 维护矫正 2 统计保养 3 网络连接 4 报告文件 5 默认设置 6 更新
    property int typePage: -1
    property int first: 0
    property int issave: 0
    color: "#E0E6E9"

    LogWindow{
        id:logwindow
    }

    // 页面切换动画配置
    property int animationDuration: 300  // 动画时长300ms
    property var easingType: Easing.InOutQuad  // 缓动曲线

    Connections{
        target: CExeConfig
        onMaskingInformation:{
            if(value[0]==="1"&&value[1]==="0"){
                pbflag=1
                typePage=0
            }else if(value[0]==="0"&&value[1]==="1"){
                pbflag=2
                typePage=3
            }else{
                pbflag=3
            }
        }
        onDelv3:{
            dddelv3.show()
        }
    }

    Config{
        id: config
    }
    StatePOP{
        id:statepop
    }

    BoxOperating{
        id: box_operatingPref
    }
    CustomPopupBoxWarning{
        id: dddelv3
        showRejectedButton: false
        box_text: "删除失败，等待步骤不可删除！"
    }
    CustomPopupBoxWarning{
        id: zyrdpop
        showRejectedButton: false
        box_text: "请输入100-700之间数字！"
    }
    CustomPopupBoxWarning{
        id: rdpop
        showRejectedButton: false
        box_text: "请输入100-350之间数字！"
    }
    CustomPopupBoxWarning{
        id: ddpop
        showRejectedButton: false
        box_text: "保存失败，请输入小于当前步骤号的数字！"
    }
    CustomPopupBoxWarning{
        id: ddpop2
        box_text: "参数未填写，请确认是否保存！"
    }

    onVisibleChanged: {
        if(visible){
            gIsShowPrefSettings = true
        }
        var value = CExeConfig.getMaskingInformation()
        if(value[0]==="1"&&value[1]==="0"){
            pbflag=1
            typePage=0
        }else if(value[0]==="0"&&value[1]==="1"){
            pbflag=2
            typePage=3
        }else{
            pbflag=3
        }
    }

    // 顶部分类按钮区域
    Rectangle{
        visible: curPage===0||(curPage===1&&mainpas.visible===false)
        x: 240*dp; y: parent.height*0.1-60*dp
        width: 800*dp
        height: 60*dp
        color: "transparent"
        Text {
            id: tit
            text: {
                if(curPage===0) return qsTr("实验配置:");
                else if(curPage===1) return qsTr("维护校正:");
            }
            font.bold: true
            font.pixelSize: config.fontsize + 5*dp
            width: 120*dp
            height: 40*dp
            x:0*dp
            y:15*dp
        }
        CustomButton{
            visible: pbflag===1||pbflag===3
            title: curPage===0?"放靶":"放靶/转靶"
            x:typePage===0?120*dp:140*dp
            y:typePage===0?0*dp:10*dp
            width: typePage===0?160*dp:120*dp
            height: typePage===0?62*dp:40*dp
            button_color: typePage===0?"white":"#f0f3f4"
            text_color: typePage===0?"#1677FF":"black"
            onReleased: typePage=0
        }
        CustomButton{
            visible: pbflag===1||pbflag===3
            title: "打靶"
            x:typePage===1?280*dp:300*dp
            y:typePage===1?0*dp:10*dp
            width: typePage===1?160*dp:120*dp
            height: typePage===1?62*dp:40*dp
            button_color: typePage===1?"white":"#f0f3f4"
            text_color: typePage===1?"#1677FF":"black"
            onReleased: typePage=1
        }
        CustomButton{
            visible: (pbflag===1||pbflag===3)&&curPage===0
            title: "转靶"
            x:typePage===2?440*dp:460*dp
            y:typePage===2?0*dp:10*dp
            width: typePage===2?160*dp:120*dp
            height: typePage===2?62*dp:40*dp
            button_color: typePage===2?"white":"#f0f3f4"
            text_color: typePage===2?"#1677FF":"black"
            onReleased: typePage=2
        }
        CustomButton{
            visible: pbflag===2||pbflag===3
            title: "纯化"
            x:{
                if (typePage === 3 && pbflag === 2) return 120 * dp;
                if (typePage === 3 && pbflag !== 2 &&curPage===0) return 600 * dp;
                if (typePage !== 3 && pbflag === 2) return 140 * dp;
                if (typePage !== 3 && pbflag !== 2 &&curPage===0) return 620 * dp;
                if (typePage === 3 && pbflag !== 2 &&curPage===1) return 440 * dp;
                if (typePage !== 3 && pbflag !== 2 &&curPage===1) return 460 * dp;
            }
            y:typePage===3?0*dp:10*dp
            width: typePage===3?160*dp:120*dp
            height: typePage===3?62*dp:40*dp
            button_color: typePage===3?"white":"#f0f3f4"
            text_color: typePage===3?"#1677FF":"black"
            onReleased: typePage=3
        }
        CustomButton{
            visible:  curPage === 0 && (pbflag===1||pbflag===3)
            title: "项目配置"
            x:{
                if (typePage === 4 && pbflag === 1) return 600 * dp;
                if (typePage === 4 && pbflag !== 1) return 760 * dp;
                if (typePage !== 4 && pbflag === 1) return 620 * dp;
                if (typePage !== 4 && pbflag !== 1) return 780 * dp;
            }
            y:typePage===4?0*dp:10*dp
            width: typePage===4?160*dp:120*dp
            height: typePage===4?62*dp:40*dp
            button_color: typePage===4?"white":"#f0f3f4"
            text_color: typePage===4?"#1677FF":"black"
            onReleased: typePage=4
        }
        CustomButton{
            visible:  curPage === 1
            title: "故障"
            x:{
                if (typePage === 4 && pbflag === 1) return 440 * dp;
                if (typePage === 4 && pbflag === 2) return 280 * dp;
                if (typePage !== 4 && pbflag === 1) return 460 * dp;
                if (typePage !== 4 && pbflag === 2) return 300 * dp;
                if (typePage === 4 && pbflag !== 1 && pbflag !== 2) return 600 * dp;
                if (typePage !== 4 && pbflag !== 1 && pbflag !== 2) return 620 * dp;
            }
            y:typePage===4?0*dp:10*dp
            width: typePage===4?160*dp:120*dp
            height: typePage===4?62*dp:40*dp
            button_color: typePage===4?"white":"#f0f3f4"
            text_color: typePage===4?"#1677FF":"black"
            onReleased: typePage=4
        }
        CustomButton{
            visible:  curPage === 1
            title: "检测"
            x:{
                if (typePage === 5 && pbflag === 1) return 600 * dp;
                if (typePage === 5 && pbflag === 2) return 440 * dp;
                if (typePage !== 5 && pbflag === 1) return 620 * dp;
                if (typePage !== 5 && pbflag === 2) return 460 * dp;
                if (typePage === 5 && pbflag !== 1 && pbflag !== 2) return 760 * dp;
                if (typePage !== 5 && pbflag !== 1 && pbflag !== 2) return 780 * dp;
            }
            y:typePage===5?0*dp:10*dp
            width: typePage===5?160*dp:120*dp
            height: typePage===5?62*dp:40*dp
            button_color: typePage===5?"white":"#f0f3f4"
            text_color: typePage===5?"#1677FF":"black"
            onReleased: typePage=5
        }
    }

    // 左侧按钮样式初始化
    Component.onCompleted: {
        var buttonList = column_button.children;
        for(let i = 0; i < buttonList.length; i ++){
            buttonList[i].height = Qt.binding(function(){ return 55*dp })
            buttonList[i].width = Qt.binding(function(){ return 140*dp })
            buttonList[i].radius = Qt.binding(function(){ return 28*dp })
            buttonList[i].icon_size = Qt.binding(function(){ return 28*dp })
            buttonList[i].button_color = "white"
            buttonList[i].button_border = "#CCCCCC"
            buttonList[i].text_color   = "#333333"
            buttonList[i].button_color_select = "#1677FF"
            buttonList[i].button_border_select = "transparent"
            buttonList[i].text_color_select   = "#FFFFFF"
            buttonList[i].button_color_hover = "#1677FF"
            buttonList[i].text_color_hover = "white"
        }
    }

    // 左侧按钮列
    Column{
        id: column_button
        x: 20*dp; y: parent.height*0.16
        spacing: 15*dp
        CustomButton{
            title: "网络连接"
            button_icon: "qrc:/picture/preferenceTab/net0.png"
            button_icon_select: "qrc:/picture/preferenceTab/net1.png"
            isSelected: curPage === 3
            enabled: gExpIsRunning === 0 || gExpIsFailurePause
            button_icon_hover: "qrc:/picture/preferenceTab/net1.png"
            onReleased: {
                curPage = 3
                typePage = 0
            }
        }
        CustomButton{
            title: "实验配置"
            button_icon: "qrc:/picture/preferenceTab/settings0.png"
            button_icon_select: "qrc:/picture/preferenceTab/settings1.png"
            isSelected: curPage === 0
            enabled: gExpIsRunning === 0
            button_icon_hover: "qrc:/picture/preferenceTab/settings1.png"
            onReleased: {
                curPage = 0
                if(pbflag===2){
                    typePage = 3
                }else{
                    typePage = 0
                }
            }
        }
        CustomButton{
            title: "报告文件"
            button_icon: "qrc:/picture/preferenceTab/report0.png"
            button_icon_select: "qrc:/picture/preferenceTab/report1.png"
            isSelected: curPage === 4
            enabled: gExpIsRunning === 0
            button_icon_hover: "qrc:/picture/preferenceTab/report1.png"
            onReleased: {
                curPage = 4
                typePage = 0
            }
        }
        CustomButton{
            title: "默认设置"
            button_icon: "qrc:/picture/preferenceTab/default0.png"
            button_icon_select: "qrc:/picture/preferenceTab/default1.png"
            isSelected: curPage === 5
            enabled: gExpIsRunning === 0
            button_icon_hover: "qrc:/picture/preferenceTab/default1.png"
            onReleased: {
                curPage = 5
                typePage = 0
            }
        }
        CustomButton{
            title: "维护校正"
            button_icon: "qrc:/picture/preferenceTab/maintain0.png"
            button_icon_select: "qrc:/picture/preferenceTab/maintain1.png"
            isSelected: curPage === 1
            enabled: gExpIsRunning === 0 || gExpIsFailurePause
            button_icon_hover: "qrc:/picture/preferenceTab/maintain1.png"
            onReleased: {
                curPage = 1
                if(pbflag===2){
                    typePage = 3
                }else{
                    typePage = -1
                }
            }
        }
        CustomButton{
            title: "语音模块"
            button_icon: "qrc:/picture/preferenceTab/microphone0.png"
            button_icon_select: "qrc:/picture/preferenceTab/microphone1.png"
            isSelected: curPage === 7
            enabled: gExpIsRunning === 0
            button_icon_hover: "qrc:/picture/preferenceTab/microphone1.png"
            onReleased: {
                curPage = 7
                typePage = 0
            }
        }
        CustomButton{
            title: "统计保养"
            button_icon: "qrc:/picture/preferenceTab/statistics0.png"
            button_icon_select: "qrc:/picture/preferenceTab/statistics1.png"
            isSelected: curPage === 2
            enabled: gExpIsRunning === 0
            button_icon_hover: "qrc:/picture/preferenceTab/statistics1.png"
            onReleased: {
                curPage = 2
                typePage = 0
            }
        }
        CustomButton{
            title: " 摄 像 头"
            button_icon: "qrc:/picture/preferenceTab/camera0.png"
            button_icon_select: "qrc:/picture/preferenceTab/camera1.png"
            isSelected: curPage === 9
            enabled: gExpIsRunning === 0
            button_icon_hover: "qrc:/picture/preferenceTab/camera1.png"
            onReleased: {
                curPage = 9
                typePage = 0
            }
        }

        CustomButton{
            title: "更       新"
            button_icon: "qrc:/picture/preferenceTab/update0.png"
            button_icon_select: "qrc:/picture/preferenceTab/update1.png"
            isSelected: curPage === 6
            enabled: gExpIsRunning === 0
            button_icon_hover: "qrc:/picture/preferenceTab/update1.png"
            onReleased: {
                curPage = 6
                typePage = 0
            }
        }
        CustomButton{
            title: "帮        助"
            button_icon: "qrc:/picture/preferenceTab/help0.png"
            button_icon_select: "qrc:/picture/preferenceTab/help1.png"
            isSelected: curPage === 8
            button_icon_hover: "qrc:/picture/preferenceTab/help1.png"
            onReleased: {
                curPage = 8
                typePage = 0
            }
        }
    }

    // 主内容区域（带淡入淡出动画）
    Item {
        x: 180 * dp
        y: parent.height * 0.1
        width: preferenceSettings.width - x - 40 * dp
        height: preferenceSettings.height - parent.height * 0.2

        // 淡入淡出过渡动画定义
        property var fadeTransition: Transition {
            NumberAnimation {
                properties: "opacity"
                duration: preferenceSettings.animationDuration
                easing.type: preferenceSettings.easingType
            }
        }
        StatMaint{         // 统计保养
            id:staticMaintenance
            width: parent.width;  height:parent.height
            visible: curPage===2
            radius: 12
            opacity: 0
        }
        AutoExportPage{         // 报告文件
            id:reportFile
            width: parent.width;  height:parent.height
            visible: curPage===4
            radius: 12
            opacity: 0
        }
        DefSet{
            id:defaultSetting
            width: parent.width;  height:parent.height
            visible: curPage===5
            radius: 12
            opacity: 0
        }
        UpData{
            id:updateSoft
            width: parent.width;  height:parent.height
            visible: curPage===6
            radius: 12
            opacity: 0
        }
        NetworkConnect{
            id: networkConnections
            width: parent.width;  height:parent.height
            visible: curPage===3
            radius: 12
            opacity: 0
        }
        SpeechMod{
            id: speechmod
            width: parent.width;  height:parent.height
            visible: curPage===7
            radius: 12
            opacity: 0
        }
        Help{
            id: help
            width: parent.width;  height:parent.height
            visible: curPage===8
            radius: 12
            opacity: 0
        }
        CameraConfig{
            id: cameraConfig
            width: parent.width; height: parent.height
            visible: curPage===9
            radius: 12
            opacity: 0
        }

        // 2. 实验配置相关页面（curPage=0）
        ExeSetting{
            id: exeSet
            width: parent.width; height: parent.height
            visible: curPage===0&&typePage===3
            radius: 12
            opacity: 0
        }
        ZBExeSetting{
            id: zbexeSet
            width: parent.width; height: parent.height
            visible: curPage===0&&typePage===2
            radius: 12
            opacity: 0
        }
        DBExeSetting{
            id: dbexeSet
            width: parent.width; height: parent.height
            visible: curPage===0&&typePage===1
            radius: 12
            opacity: 0
        }
        FBExeSetting{
            id: fbexeSet
            width: parent.width; height: parent.height
            visible: curPage===0&&typePage===0
            radius: 12
            opacity: 0
        }
        ExConfig{
            id: exconfig
            width: parent.width; height: parent.height
            visible: curPage===0&&typePage===4
            radius: 12
            opacity: 0
        }

        // 3. 维护校正相关页面（curPage=1）
        MaintenanceWin{
            id: mainw
            width: parent.width; height: parent.height
            visible: curPage===1&&typePage===3
            radius: 12
            opacity: 0
        }
        FBMaintenance{
            id: fbMain
            width: parent.width; height: parent.height
            visible: curPage===0&&typePage===0
            radius: 12
            opacity: 0
        }
        DBMaintenance{
            id: dbMain
            width: parent.width; height: parent.height
            visible: curPage===0&&typePage===1
            radius: 12
            opacity: 0
        }
        ZBMaintenance{
            id: zbMain
            width: parent.width; height: parent.height
            visible: curPage===0&&typePage===3
            radius: 12
            opacity: 0
        }
        GZWHwin{
            id: gzwh
            width: parent.width; height: parent.height
            visible: curPage===0&&typePage===4
            radius: 12
            opacity: 0
        }
        JCWHwin{
            id: jcwh
            width: parent.width; height: parent.height
            visible: curPage===0&&typePage===5
            radius: 12
            opacity: 0
        }

        // 4. 密码输入框
        CustomInputPassword{
            id: mainpas
            width: parent.width;  height:parent.height
//            visible: curPage === 1
            opacity: 0

        }

        // 鼠标区域
//        MouseArea{
//            anchors.fill: parent
//            hoverEnabled: true
//            visible: mainpas.visible
//        }

        // 页面显隐状态与动画控制
        states: [
            // 实验配置页面状态
//            State {
//                name: "mainpasVisible"
//                when: curPage === 1
//                PropertyChanges { target: mainpas; visible: true; opacity: 1 }
//            },
            State {
                name: "exeSetVisible"
                when: curPage === 0 && typePage === 3
                PropertyChanges { target: exeSet; visible: true; opacity: 1 }
                PropertyChanges { target: zbexeSet; visible: false; opacity: 0 }
                PropertyChanges { target: dbexeSet; visible: false; opacity: 0 }
                PropertyChanges { target: fbexeSet; visible: false; opacity: 0 }
                PropertyChanges { target: exconfig; visible: false; opacity: 0 }
            },
            State {
                name: "zbexeSetVisible"
                when: curPage === 0 && typePage === 2
                PropertyChanges { target: exeSet; visible: false; opacity: 0 }
                PropertyChanges { target: zbexeSet; visible: true; opacity: 1 }
                PropertyChanges { target: dbexeSet; visible: false; opacity: 0 }
                PropertyChanges { target: fbexeSet; visible: false; opacity: 0 }
                PropertyChanges { target: exconfig; visible: false; opacity: 0 }
            },
            State {
                name: "dbexeSetVisible"
                when: curPage === 0 && typePage === 1
                PropertyChanges { target: exeSet; visible: false; opacity: 0 }
                PropertyChanges { target: zbexeSet; visible: false; opacity: 0 }
                PropertyChanges { target: dbexeSet; visible: true; opacity: 1 }
                PropertyChanges { target: fbexeSet; visible: false; opacity: 0 }
                PropertyChanges { target: exconfig; visible: false; opacity: 0 }
            },
            State {
                name: "fbexeSetVisible"
                when: curPage === 0 && typePage === 0
                PropertyChanges { target: exeSet; visible: false; opacity: 0 }
                PropertyChanges { target: zbexeSet; visible: false; opacity: 0 }
                PropertyChanges { target: dbexeSet; visible: false; opacity: 0 }
                PropertyChanges { target: fbexeSet; visible: true; opacity: 1 }
                PropertyChanges { target: exconfig; visible: false; opacity: 0 }
            },
            State {
                name: "exconfigVisible"
                when: curPage === 0 && typePage === 4
                PropertyChanges { target: exeSet; visible: false; opacity: 0 }
                PropertyChanges { target: zbexeSet; visible: false; opacity: 0 }
                PropertyChanges { target: dbexeSet; visible: false; opacity: 0 }
                PropertyChanges { target: fbexeSet; visible: false; opacity: 0 }
                PropertyChanges { target: exconfig; visible: true; opacity: 1 }
            },

            // 维护校正页面状态
            State {
                name: "mainpasVisible"
                when: curPage === 1 && typePage === -1
                PropertyChanges { target: mainpas; visible: true; opacity: 1 }
                PropertyChanges { target: mainw; visible: false; opacity: 0 }
                PropertyChanges { target: fbMain; visible: false; opacity: 0 }
                PropertyChanges { target: dbMain; visible: false; opacity: 0 }
                PropertyChanges { target: zbMain; visible: false; opacity: 0 }
                PropertyChanges { target: gzwh; visible: false; opacity: 0 }
                PropertyChanges { target: jcwh; visible: false; opacity: 0 }
            },
            State {
                name: "mainwVisible"
                when: curPage === 1 && typePage === 3
                PropertyChanges { target: mainpas; visible: false; opacity: 0 }
                PropertyChanges { target: mainw; visible: true; opacity: 1 }
                PropertyChanges { target: fbMain; visible: false; opacity: 0 }
                PropertyChanges { target: dbMain; visible: false; opacity: 0 }
                PropertyChanges { target: zbMain; visible: false; opacity: 0 }
                PropertyChanges { target: gzwh; visible: false; opacity: 0 }
                PropertyChanges { target: jcwh; visible: false; opacity: 0 }
            },
            State {
                name: "fbMainVisible"
                when: curPage === 1 && typePage === 0
                PropertyChanges { target: mainpas; visible: false; opacity: 0 }
                PropertyChanges { target: mainw; visible: false; opacity: 0 }
                PropertyChanges { target: fbMain; visible: true; opacity: 1 }
                PropertyChanges { target: dbMain; visible: false; opacity: 0 }
                PropertyChanges { target: zbMain; visible: false; opacity: 0 }
                PropertyChanges { target: gzwh; visible: false; opacity: 0 }
                PropertyChanges { target: jcwh; visible: false; opacity: 0 }
            },
            State {
                name: "dbMainVisible"
                when: curPage === 1 && typePage === 1
                PropertyChanges { target: mainpas; visible: false; opacity: 0 }
                PropertyChanges { target: mainw; visible: false; opacity: 0 }
                PropertyChanges { target: fbMain; visible: false; opacity: 0 }
                PropertyChanges { target: dbMain; visible: true; opacity: 1 }
                PropertyChanges { target: zbMain; visible: false; opacity: 0 }
                PropertyChanges { target: gzwh; visible: false; opacity: 0 }
                PropertyChanges { target: jcwh; visible: false; opacity: 0 }
            },
            State {
                name: "zbMainVisible"
                when: curPage === 1 && typePage === 2
                PropertyChanges { target: mainpas; visible: false; opacity: 0 }
                PropertyChanges { target: mainw; visible: false; opacity: 0 }
                PropertyChanges { target: fbMain; visible: false; opacity: 0 }
                PropertyChanges { target: dbMain; visible: false; opacity: 0 }
                PropertyChanges { target: zbMain; visible: true; opacity: 1 }
                PropertyChanges { target: gzwh; visible: false; opacity: 0 }
                PropertyChanges { target: jcwh; visible: false; opacity: 0 }
            },
            State {
                name: "gzwhVisible"
                when: curPage === 1 && typePage === 4
                PropertyChanges { target: mainpas; visible: false; opacity: 0 }
                PropertyChanges { target: mainw; visible: false; opacity: 0 }
                PropertyChanges { target: fbMain; visible: false; opacity: 0 }
                PropertyChanges { target: dbMain; visible: false; opacity: 0 }
                PropertyChanges { target: zbMain; visible: false; opacity: 0 }
                PropertyChanges { target: gzwh; visible: true; opacity: 1 }
                PropertyChanges { target: jcwh; visible: false; opacity: 0 }
            },
            State {
                name: "jcwhVisible"
                when: curPage === 1 && typePage === 5
                PropertyChanges { target: mainpas; visible: false; opacity: 0 }
                PropertyChanges { target: mainw; visible: false; opacity: 0 }
                PropertyChanges { target: fbMain; visible: false; opacity: 0 }
                PropertyChanges { target: dbMain; visible: false; opacity: 0 }
                PropertyChanges { target: zbMain; visible: false; opacity: 0 }
                PropertyChanges { target: gzwh; visible: false; opacity: 0 }
                PropertyChanges { target: jcwh; visible: true; opacity: 1 }
            },

            // 密码输入框状态

            State {
                name: "staticVisible"
                when: curPage === 2
                PropertyChanges { target: staticMaintenance; visible: true; opacity: 1 }
            },
            State {
                name: "reportFileVisible"
                when: curPage === 4
                PropertyChanges { target: reportFile; visible: true; opacity: 1 }
            },
            State {
                name: "defaultSettingVisible"
                when: curPage === 5
                PropertyChanges { target: defaultSetting; visible: true; opacity: 1 }
            },
            State {
                name: "updateSoftVisible"
                when: curPage === 6
                PropertyChanges { target: updateSoft; visible: true; opacity: 1 }
            },
            State {
                name: "networkConnectionsVisible"
                when: curPage === 3
                PropertyChanges { target: networkConnections; visible: true; opacity: 1 }
            },
            State {
                name: "speechmodVisible"
                when: curPage === 7
                PropertyChanges { target: speechmod; visible: true; opacity: 1 }
            },
            State {
                name: "helpVisible"
                when: curPage === 8
                PropertyChanges { target: help; visible: true; opacity: 1 }
            },
            State {
                name: "cameraVisible"
                when: curPage === 9
                PropertyChanges { target: cameraConfig; visible: true; opacity: 1 }
            }
        ]

        // 为所有页面添加淡入淡出过渡
        transitions: [
            Transition {
                // 移除 targets 属性，通过状态变化自动匹配
                NumberAnimation {
                    properties: "opacity"
                    duration: preferenceSettings.animationDuration
                    easing.type: preferenceSettings.easingType
                }
                // 切换时先隐藏所有其他页面
                onRunningChanged: {
                    if (!running) return;
                    // 手动获取所有页面组件列表
                    const pages = [exeSet, zbexeSet, dbexeSet, fbexeSet, exconfig,
                                  mainw, fbMain, dbMain, zbMain, gzwh, jcwh, mainpas,staticMaintenance,
                                reportFile,defaultSetting,updateSoft,networkConnections,speechmod,help,cameraConfig];
                    for (let i = 0; i < pages.length; i++) {
                        let page = pages[i];
                        // 非当前激活状态的页面设置为透明
                        if (!page.visible || (page.visible && page.opacity < 1)) {
                            page.opacity = 0;
                        }
                    }
                }
            }
        ]

        // 初始化页面状态
        Component.onCompleted: {
            const pages = [exeSet, zbexeSet, dbexeSet, fbexeSet, exconfig,
                          mainw, fbMain, dbMain, zbMain, gzwh, jcwh, mainpas,staticMaintenance,
                        reportFile,defaultSetting,updateSoft,speechmod,help];
            pages.forEach(page => {
                page.visible = false;
                page.opacity = 0;
            });
        }
    }

    // 故障信息弹窗
    BoxFailureInfo_plus{
        id: box_failureInfo2
    }
    Connections{
        target: CSignal
        onSendErrorMsg: {
            if(!gIsShowPrefSettings) { return }

            console.log("sendErrorMsg", errorInfo, methodInfo, errorType)

            if(gExpIsRunning === 1){
                gExpIsFailure = gExpIsFailure | (errorType+1)
            }

            if(methodInfo === "是"){
                box_failureInfo2.showContinueButton = Math.max(box_failureInfo2.showContinueButton, 0)
            }else if(methodInfo === "否"){
                box_failureInfo2.showContinueButton = 1
            }else{
                box_failureInfo2.showContinueButton = 2
            }
            // 刷新故障信息
            let errorList = errorInfo.split("\n")
            for(let i = 0; i < errorList.length; i ++){
                if(errorList[i] !== "")
                    box_failureInfo2.failureInfoList.push([errorList[i], errorType===0?"流程":"并发"])
            }
            box_failureInfo2.failureInfoListChanged()
            box_failureInfo2.show()
        }
    }

    // 提示框
    Toast{
        id: toast_settings
        y: 100*dp
        x: parent.width / 2 - 150*dp
        z: 100
    }
}
